﻿<div ng-controller="dayOrderListC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">日使用情况</h1>
    </div>
    <div class="wrapper-md" style="text-align: center;">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12" style="float: right">
                    <a class="btn btn-sm btn-default" href="../api/Report/ExpDailyUsage?createTime={{qTime.format('yyyy-MM-dd')}}">
                        <i class="fa fa-cloud-download text"></i>
                        <span class="text">全部导出</span>
                    </a>
                </div>
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 input-group">
                    <span class="input-group-addon">查询日期</span>
                    <input type="date" class="form-control" placeholder="按日期查找" ng-model="qTime">
                    <!--<span class="input-group-addon">事业部</span>
                    <select class="form-control" placeholder="按事业部查找" ng-options=" x.Name for x in arr track by x.Id" ng-model="dept"></select>-->
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button" ng-click="find()">查找</button>
                    </span>
                </div>
            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light table-bordered">
                    <thead>
                        <tr>
                            <th style="text-align: center;" ng-repeat="item in neworders[0] track by $index">{{item}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="ord in orders track by $index">
                            <td class="text-center" ng-repeat="item in ord track by $index">{{item}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app') //锁价单列表控制器
    //每日使用情况
    .controller("DailyUsageC", function ($scope, $state, $http) {
        $scope.qTime = new Date();
        //$scope.dept = "";
        $scope.getData = function () {
            $http({
                url: "../api/Report/DailyUsage?isHander=true&createTime=" + $scope.qTime.format('yyyy-MM-dd'),
                method: "GET"
            })
                    .then(function (res) {
                        $scope.orders = res.data;
                    })
                    .then(function (error) {
                        if (error) {
                            alert("数据获取失败");
                        }
                    });
        };
        $scope.find = function () {
            $scope.getData();
        };

        //加载数据
        $scope.getData();
        $http.get('../api/Department')
     .success(function (res) {
         $scope.departments = res.Data;
         $scope.traverseTree($scope.departments);
         $scope.dept = $scope.departments[0].Item2;
     });
        $scope.arr = [];
        $scope.traverseTree = function (node) {
            for (var i = 0; i < node.length; i++) {
                var empty = '　└─';
                for (var j = 1; j < node[i].Item1; j++) {
                    empty = '　　' + empty;
                }
                if (i != 0) {
                    node[i].Item2.Name = empty + node[i].Item2.Name;
                } else {
                    node[i].Item2.Name = '　' + node[i].Item2.Name;
                }
                $scope.arr.push(node[i].Item2);
            }
            $scope.arr[0].selected = true;
        };
    })
</script>